/*
 *
 * Created on: 24.06.2012
 *
 * DHLogAnalyzer.h
 * This file is part of KOBUS
 * 
 * Copyright (C) 2012 - Ivan Penkin, MIPT
 * grek.penkin@gmail.com
 *
 * KOBUS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * KOBUS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with KOBUS; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, 
 * Boston, MA  02110-1301  USA
 *  
 */

#ifndef DHLOGANALYZER_H_
#define DHLOGANALYZER_H_


#include <QtCore>
#include <QtNetwork>

#include <TCPCoreClient.h>
#include <DHConfig.h>
#include <DHReleaseParser.h>
#include <DHAcknowledgementParser.h>


namespace kobus{
namespace dhcp{


class DHLogAnalyzer: public QObject
{
    Q_OBJECT

  public:
    explicit
    DHLogAnalyzer( QObject * parent = 0 );

    virtual
    ~DHLogAnalyzer();

  public slots:
    void start();
    void terminate();

  private:
    Q_DISABLE_COPY(DHLogAnalyzer);

    inline
    void processDhcpAck();
    inline
    int checkDhcpAckData();
    inline
    void processDhcpRelease();
    inline
    int checkDhcpReleaseData();

    DHConfig      config;
    QString       message;
    QStringList   interfaces;

    DHAcknowledgementParser acknowledgementParser;
    DHReleaseParser         releaseParser;

    QProcess      * tail;
    QThread       * coreThread;
    TCPCoreClient * core;

  private slots:
    void startTail();
    void onError();
    void processTailMessage();

  signals:
};

} /* namespace dhcp */
} /* namespace kobus */

#endif /* DHLOGANALYZER_H_ */
